package main;

import java.util.Iterator;
import java.util.LinkedList;




import main.Main.command;

public class Manager {
	public void print(command cmd, CommandDb dbCmd, ConsoleInput in) throws Exception {
		switch (cmd) {
		case getAll:
			LinkedList<Workers> men = dbCmd.getAll();
			for(Iterator<Workers> i = men.iterator(); i.hasNext();) {
				Workers temp = i.next();
				System.out.println(temp.getId()+". "+temp.get_name() + " " + temp.get_surname() + ", age: " 
									+ temp.getAge() + ", salary: " + temp.getSalary());
				temp = null;
			}
			break;
		case add:
			System.out.println("Enter new data.");
			Workers tempMan = new Workers();
			tempMan.set_name(in.getStringData("name"));
			tempMan.set_surname(in.getStringData("surname"));
			tempMan.setAge(in.getIntData("age"));
			tempMan.setSalary(in.getIntData("salary"));
			dbCmd.add(tempMan);
			tempMan = null;
			break;
		case edit: 
			System.out.println("Enter updating data.");
			Workers temp = new Workers();
			temp.setId(in.getIntData("id"));
			temp.set_name(in.getStringData("name"));
			temp.set_surname(in.getStringData("surname"));
			temp.setAge(in.getIntData("age"));
			temp.setSalary(in.getIntData("salary"));
			dbCmd.update(temp);
			break;
		case delete:
			System.out.println("Enter item id to be deleted: ");
			dbCmd.delete(in.getIntData("id"));
			break;
		case exit: System.out.println("Thanks for testing! :)");
			break;
		}
	}
}
